#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:do_queue2.py
# author: 马国鑫
# datetime:2022/3/30 22:13
# software: PyCharm

"""
this is function  description 
"""

# import module your need

# 实现进程间通信
import time
import multiprocessing


def write_queue(queue):
    for i in range(10):
        if queue.full():
            print('队列已满！')
            break
        queue.put(i)
        print('队列已经加入:',i)
        time.sleep(0.5)


def read_queue(queue):
    while True:
        if queue.qsize() == 0:
            print('队列空')
            break
        data = queue.get()
        print(data)


if __name__ == '__main__':
    queue = multiprocessing.Queue(5)
    wq = multiprocessing.Process(target=write_queue, args=(queue,))
    rq = multiprocessing.Process(target=read_queue, args=(queue,))
    wq.start()
    wq.join()
    rq.start()

